let arr = [2, 0, 2, 1, 8, 7, 0, 3, 6, 1, 9];

let insertionSort = arr => {
    for (let i = 0; i < arr.length - 1; i++) {
        for (let j = i + 1; j > 0; j--) {
            if (arr[j] < arr[j - 1]) {
                [arr[j - 1], arr[j]] = [arr[j], arr[j - 1]]
            } else { //不需要交换
                break;
            }
        }
    }
    return arr;
}

console.log(insertionSort(arr))